namespace QMVnSoft.Invoices
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.Controls.ChildGridControls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormCTDHEditor : FormEditor
    {
        private NumericColumn Column1;
        private DataGridViewTextBoxColumn Column10;
        private OptionColumn Column11;
        private SearchColumn Column12;
        private SearchColumn Column13;
        private DataGridViewTextBoxColumn Column14;
        private NumericColumn Column15;
        private NumericColumn Column16;
        private NumericColumn Column17;
        private NumericColumn Column18;
        private NumericColumn Column2;
        private NumericColumn Column3;
        private DataGridViewCheckBoxColumn Column4;
        private SearchColumn Column9;
        private IContainer components;
        private GridDetail grdDetail;
        private bool ib_FromRequirement;
        private LabelControl lblDesc_EN;
        private LabelControl lblDia_Chi;
        private LabelControl lblDien_Giai;
        private LabelControl lblEmail;
        private LabelControl lblGhi_Chu;
        private LabelControl lblMa_Bp;
        private LabelControl lblMa_Dt;
        private LabelControl lblMa_Hd;
        private LabelControl lblMa_Nv;
        private LabelControl lblMa_Tte;
        private LabelControl lblNgay_GH;
        private LabelControl lblNoi_GH;
        private LabelControl lblOng_Ba;
        private LabelControl lblPhones;
        private LabelControl lblTTien_Nt0;
        private CTDHDataAccess oMethod;
        private TextControl txtDesc_EN;
        private TextControl txtDia_Chi;
        private TextControl txtDien_Giai;
        private TextControl txtEmail;
        private TextControl txtGhi_Chu;
        private TextSearch txtMa_Bp;
        private TextSearch txtMa_Dt;
        private TextSearch txtMa_Hd;
        private TextSearch txtMa_Nv;
        private TextOption txtMa_Tte;
        private TextDate txtNgay_GH;
        private TextControl txtNoi_GH;
        private TextControl txtOng_Ba;
        private TextControl txtPhones;
        private TextControl txtTen_Bp;
        private TextControl txtTen_Dt;
        private TextControl txtTen_Hd;
        private TextControl txtTen_Nv;
        private TextNumeric txtTTien_Nt0;
        private TextNumeric txtTy_Gia;

        public FormCTDHEditor()
        {
            this.oMethod = new CTDHDataAccess();
            this.InitializeComponent();
            this.SetFunctions();
            base.DetailGridBrowser.CellEnter += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEnter);
            base.DetailGridBrowser.CellEndEdit += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEndEdit);
            base.ResizeForm();
        }

        public FormCTDHEditor(AppInvoiceLib po_AppInvoiceLib) : base(po_AppInvoiceLib)
        {
            this.oMethod = new CTDHDataAccess();
            this.InitializeComponent();
            this.SetFunctions();
            base.InvoiceCode = po_AppInvoiceLib.InvoiceCode;
            base.DetailGridBrowser.CellEnter += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEnter);
            base.DetailGridBrowser.CellEndEdit += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEndEdit);
            base.ResizeForm();
        }

        public FormCTDHEditor(string ps_InvoiceCode, DataRow po_RequireRow)
        {
            this.oMethod = new CTDHDataAccess();
            this.InitializeComponent();
            this.FormRequirement = true;
            this.SetFunctions();
            base.InvoiceCode = ps_InvoiceCode;
            base.DetailGridBrowser.CellEnter += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEnter);
            base.DetailGridBrowser.CellEndEdit += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEndEdit);
            this.RequireOrder(po_RequireRow);
            this.OnShow();
            base.ResizeForm();
        }

        public FormCTDHEditor(string ps_InvoiceCode, string ps_MasterInvoiceOrder) : base(ps_InvoiceCode, ps_MasterInvoiceOrder)
        {
            this.oMethod = new CTDHDataAccess();
            this.InitializeComponent();
            this.SetFunctions();
            base.InvoiceCode = ps_InvoiceCode;
            base.DetailGridBrowser.CellEnter += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEnter);
            base.DetailGridBrowser.CellEndEdit += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEndEdit);
            base.LocalMasterRow = this.oMethod.GetMasterDataRow(base.SavedMasterOrder);
            base.LocalDetailDataSet = this.oMethod.GetDetailDataSet(base.SavedMasterOrder);
            this.OnShow();
            base.ResizeForm();
        }

        private bool AddNewRow(bool pb_Inserted)
        {
            if ((base.DetailGridBrowser.CurrentRow == null) || (base.DetailGridBrowser.CurrentRow.DataBoundItem == null))
            {
                return false;
            }
            DataRow row = ((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row;
            if ((((decimal) row["So_Luong9"]) == 0M) && (((decimal) row["Gia9"]) == 0M))
            {
                return false;
            }
            int num = 0;
            if (pb_Inserted)
            {
                num = (int) row["Stt_Nv"];
                foreach (DataRow row2 in base.LocalDetailTable.Rows)
                {
                    if ((row2.RowState != DataRowState.Deleted) && (((int) row2["Stt_Nv"]) > num))
                    {
                        row2["Stt_Nv"] = ((int) row2["Stt_Nv"]) + 1;
                    }
                }
            }
            else
            {
                foreach (DataRow row3 in base.LocalDetailTable.Rows)
                {
                    if ((row3.RowState != DataRowState.Deleted) && (((int) row3["Stt_Nv"]) > num))
                    {
                        num = (int) row3["Stt_Nv"];
                    }
                }
                if (((int) row["Stt_Nv"]) < num)
                {
                    return false;
                }
            }
            object obj2 = string.IsNullOrEmpty(this.txtMa_Bp.Text) ? row["Ma_Bp"] : this.txtMa_Bp.Value;
            object obj3 = string.IsNullOrEmpty(this.txtMa_Hd.Text) ? row["Ma_Hd"] : this.txtMa_Hd.Value;
            base.DetailGridBrowser.EndEdit();
            DataRow row4 = base.MakeDetailRow();
            int key = num + 1;
            row4["Stt_Nv"] = key;
            row4["He_So9"] = 1;
            row4["Ma_Bp"] = obj2;
            row4["Ma_Hd"] = obj3;
            row4["So_Luong9"] = 0;
            row4["Gia_Nt9"] = 0;
            row4["Gia9"] = 0;
            row4["So_Luong"] = 0;
            row4["Gia_Nt"] = 0;
            row4["Gia"] = 0;
            row4["Tien_Nt"] = 0;
            row4["Tien"] = 0;
            row4["Tien_Nt1"] = 0;
            row4["Tien1"] = 0;
            base.LocalDetailTable.Rows.Add(row4);
            BindingSource dataSource = base.DetailGridBrowser.DataSource as BindingSource;
            dataSource.Position = dataSource.Find(base.DetailOrderString, key);
            return true;
        }

        private void Calculate(int pi_Position)
        {
            DataRow row = ((DataRowView) this.grdDetail.CurrentRow.DataBoundItem).Row;
            this.Calculate(row, pi_Position);
        }

        private void Calculate(DataRow po_Row, int pi_Position)
        {
            if (pi_Position == 1)
            {
                po_Row["So_Luong"] = decimal.Round(((decimal) po_Row["So_Luong9"]) * ((decimal) po_Row["He_So9"]), base.QuantityDecimals);
                po_Row["Tien_Nt"] = decimal.Round(((decimal) po_Row["So_Luong9"]) * ((decimal) po_Row["Gia_Nt9"]), base.FCAmountDecimals);
                po_Row["Tien"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) * base.ExchangeRate, base.LCAmountDecimals);
            }
            else if (pi_Position == 3)
            {
                po_Row["Tien1"] = decimal.Round(((decimal) po_Row["Tien_Nt1"]) * base.ExchangeRate, base.LCAmountDecimals);
            }
            else if (((decimal) po_Row["So_Luong9"]) != 0M)
            {
                po_Row["Gia9"] = decimal.Round(((decimal) po_Row["Gia_Nt9"]) * base.ExchangeRate, base.LCPriceDecimals);
                po_Row["Tien_Nt"] = decimal.Round(((decimal) po_Row["So_Luong9"]) * ((decimal) po_Row["Gia_Nt9"]), base.FCAmountDecimals);
                po_Row["Tien"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) * base.ExchangeRate, base.LCAmountDecimals);
                po_Row["Gia_Nt"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) / ((decimal) po_Row["So_Luong"]), base.FCPriceDecimals);
                po_Row["Gia"] = decimal.Round(((decimal) po_Row["Gia_Nt"]) * base.ExchangeRate, base.LCPriceDecimals);
            }
            else
            {
                po_Row["Gia9"] = decimal.Round(((decimal) po_Row["Gia_Nt9"]) * base.ExchangeRate, base.LCPriceDecimals);
                po_Row["Gia_Nt"] = decimal.Round(((decimal) po_Row["Gia_Nt9"]) / ((decimal) po_Row["He_So9"]), base.FCPriceDecimals);
                po_Row["Gia"] = decimal.Round(((decimal) po_Row["Gia_Nt"]) * base.ExchangeRate, base.LCPriceDecimals);
            }
        }

        private void ChooseQuotation(object sender, EventArgs e)
        {
            if (base.txtNgay_Ct.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập ngày chứng từ!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else if (this.txtMa_Dt.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập mã đối tượng!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                DataRow row;
                DataTable table = new DataTable();
                DataColumn column = new DataColumn("Stt0_B", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Bp", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ten_Bp", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Hd", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ten_Hd", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Vt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ten_Vt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Dvt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ghi_Chu", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("He_So9", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("So_Luong9", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("Gia_Nt9", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("Gia9", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("So_Luong", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("Gia_Nt", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("Gia", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("Tien_Nt", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("Tien", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("Tien_Nt1", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("Tien1", typeof(decimal));
                table.Columns.Add(column);
                table.PrimaryKey = new DataColumn[] { table.Columns["Ma_Vt"] };
                foreach (DataRow row2 in base.LocalDetailTable.Rows)
                {
                    if (((row2.RowState != DataRowState.Deleted) && !string.IsNullOrEmpty(row2["Ma_Vt"].ToString())) && (!string.IsNullOrEmpty(row2["Stt0_B"].ToString()) && (table.Rows.Find(row2["Ma_Vt"]) == null)))
                    {
                        row = table.NewRow();
                        row["Stt0_B"] = row2["Stt0_B"];
                        row["Ma_Bp"] = row2["Ma_Bp"];
                        row["Ten_Bp"] = row2["Ten_Bp"];
                        row["Ma_Hd"] = row2["Ma_Hd"];
                        row["Ten_Hd"] = row2["Ten_Hd"];
                        row["Ma_Vt"] = row2["Ma_Vt"];
                        row["Ten_Vt"] = row2["Ten_Vt"];
                        row["Dvt"] = row2["Dvt"];
                        row["Ghi_Chu"] = row2["Ghi_Chu"];
                        row["He_So9"] = row2["He_So9"];
                        row["So_Luong9"] = row2["So_Luong9"];
                        row["Gia_Nt9"] = 0;
                        row["Gia9"] = 0;
                        row["So_Luong"] = row2["So_Luong"];
                        row["Gia_Nt"] = 0;
                        row["Gia"] = 0;
                        row["Tien_Nt"] = 0;
                        row["Tien"] = 0;
                        row["Tien_Nt1"] = 0;
                        row["Tien1"] = 0;
                        table.Rows.Add(row);
                    }
                }
                FormCTBGF4Editor editor = new FormCTBGF4Editor(base.AppInvoiceParameters.InvoiceType, base.SavedMasterOrder, base.txtNgay_Ct.Value, this.txtMa_Dt.Value, table);
                editor.ShowDialog();
                if (editor.CheckAccepted)
                {
                    int num = 0;
                    object obj2 = "";
                    object obj3 = "";
                    object obj4 = "";
                    object obj5 = "";
                    object obj6 = 0;
                    object obj7 = 0;
                    object obj8 = 0;
                    object obj9 = 0;
                    object obj10 = 0;
                    object obj11 = 0;
                    object obj12 = 0;
                    object obj13 = 0;
                    base.LocalDetailTable.AcceptChanges();
                    foreach (DataRow row3 in base.LocalDetailTable.Rows)
                    {
                        if (row3.RowState != DataRowState.Deleted)
                        {
                            row3.Delete();
                        }
                    }
                    foreach (DataRow row4 in table.Rows)
                    {
                        if (row4.RowState != DataRowState.Deleted)
                        {
                            num++;
                            row = base.MakeDetailRow();
                            obj2 = string.IsNullOrEmpty(row4["Ma_Bp"].ToString()) ? this.txtMa_Bp.Value : row4["Ma_Bp"];
                            obj3 = string.IsNullOrEmpty(row4["Ma_Bp"].ToString()) ? this.txtTen_Bp.Value : row4["Ma_Bp"];
                            obj4 = string.IsNullOrEmpty(row4["Ma_Hd"].ToString()) ? this.txtMa_Hd.Value : row4["Ma_Hd"];
                            obj5 = string.IsNullOrEmpty(row4["Ma_Hd"].ToString()) ? this.txtTen_Hd.Value : row4["Ma_Hd"];
                            obj6 = (((decimal) row4["So_Luong9"]) == 0M) ? 1M : row4["So_Luong9"];
                            obj7 = (((decimal) row4["So_Luong"]) == 0M) ? row4["He_So9"] : row4["So_Luong"];
                            obj10 = decimal.Round(((decimal) row4["Gia"]) / base.ExchangeRate, base.FCPriceDecimals);
                            obj9 = decimal.Round(((decimal) obj10) * ((decimal) row4["He_So9"]), base.LCPriceDecimals);
                            obj8 = decimal.Round((((decimal) obj10) * ((decimal) row4["He_So9"])) / base.ExchangeRate, base.FCPriceDecimals);
                            obj11 = decimal.Round(((decimal) obj6) * ((decimal) obj8), base.FCAmountDecimals);
                            obj12 = decimal.Round(((decimal) obj11) * base.ExchangeRate, base.LCAmountDecimals);
                            obj13 = decimal.Round(((decimal) row4["Tien1"]) / base.ExchangeRate, base.FCAmountDecimals);
                            row["Stt0_B"] = row4["Stt0_B"];
                            row["Stt_Nv"] = num;
                            row["Ma_Vt"] = row4["Ma_Vt"];
                            row["Ten_Vt"] = row4["Ten_Vt"];
                            row["Dvt"] = row4["Dvt"];
                            row["Ghi_Chu"] = row4["Ghi_Chu"];
                            row["He_So9"] = row4["He_So9"];
                            row["Ma_Bp"] = obj2;
                            row["Ten_Bp"] = obj3;
                            row["Ma_Hd"] = obj4;
                            row["Ten_Hd"] = obj5;
                            row["So_Luong9"] = obj6;
                            row["Gia_Nt9"] = obj8;
                            row["Gia9"] = obj9;
                            row["So_Luong"] = obj7;
                            row["Gia_Nt"] = obj10;
                            row["Gia"] = row4["Gia"];
                            row["Tien_Nt"] = obj11;
                            row["Tien"] = obj12;
                            row["Tien_Nt1"] = obj13;
                            row["Tien1"] = row4["Tien1"];
                            base.LocalDetailTable.Rows.Add(row);
                        }
                    }
                    base.DetailGridBrowser.CurrentCell = base.DetailGridBrowser.FirstDisplayedCell;
                    base.DetailGridBrowser.Focus();
                }
            }
        }

        private void ChooseRequires(object sender, EventArgs e)
        {
            if (base.txtNgay_Ct.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập ngày chứng từ!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                DataRow row;
                DataTable table = new DataTable();
                DataColumn column = new DataColumn("Stt0_D", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Bp", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Hd", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Vt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ten_Vt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Dvt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("He_So9", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("Ghi_Chu", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("So_Luong", typeof(decimal));
                table.Columns.Add(column);
                table.PrimaryKey = new DataColumn[] { table.Columns["Stt0_D"] };
                foreach (DataRow row2 in base.LocalDetailTable.Rows)
                {
                    if (((row2.RowState != DataRowState.Deleted) && !string.IsNullOrEmpty(row2["Ma_Vt"].ToString())) && !string.IsNullOrEmpty(row2["Stt0_D"].ToString()))
                    {
                        row = table.NewRow();
                        row["Stt0_D"] = row2["Stt0_D"];
                        row["Ma_Bp"] = row2["Ma_Bp"];
                        row["Ma_Hd"] = row2["Ma_Hd"];
                        row["Ma_Vt"] = row2["Ma_Vt"];
                        row["Ten_Vt"] = row2["Ten_Vt"];
                        row["Dvt"] = row2["Dvt"];
                        row["He_So9"] = row2["He_So9"];
                        row["Ghi_Chu"] = row2["Ghi_Chu"];
                        row["So_Luong"] = row2["So_Luong"];
                        table.Rows.Add(row);
                    }
                }
                FormCTYCMF4Editor editor = new FormCTYCMF4Editor(base.SavedMasterOrder, base.txtNgay_Ct.Value, table);
                editor.ShowDialog();
                if (editor.CheckAccepted)
                {
                    int num = 0;
                    object obj2 = "";
                    object obj3 = "";
                    object obj4 = 0;
                    base.LocalDetailTable.AcceptChanges();
                    foreach (DataRow row3 in base.LocalDetailTable.Rows)
                    {
                        if (row3.RowState != DataRowState.Deleted)
                        {
                            row3.Delete();
                        }
                    }
                    foreach (DataRow row4 in table.Rows)
                    {
                        if (row4.RowState != DataRowState.Deleted)
                        {
                            num++;
                            row = base.MakeDetailRow();
                            obj2 = string.IsNullOrEmpty(row4["Ma_Bp"].ToString()) ? this.txtMa_Bp.Value : row4["Ma_Bp"];
                            obj3 = string.IsNullOrEmpty(row4["Ma_Hd"].ToString()) ? this.txtMa_Hd.Value : row4["Ma_Hd"];
                            obj4 = decimal.Round(((decimal) row4["So_Luong"]) / ((decimal) row4["He_So9"]), base.QuantityDecimals);
                            row["Stt0_D"] = row4["Stt0_D"];
                            row["Stt_Nv"] = num;
                            row["Ma_Vt"] = row4["Ma_Vt"];
                            row["Ten_Vt"] = row4["Ten_Vt"];
                            row["Dvt"] = row4["Dvt"];
                            row["Ghi_Chu"] = row4["Ghi_Chu"];
                            row["He_So9"] = row4["He_So9"];
                            row["Ma_Bp"] = obj2;
                            row["Ma_Hd"] = obj3;
                            row["So_Luong9"] = obj4;
                            row["Gia_Nt9"] = 0;
                            row["Gia9"] = 0;
                            row["So_Luong"] = row4["So_Luong"];
                            row["Gia_Nt"] = 0;
                            row["Gia"] = 0;
                            row["Tien_Nt"] = 0;
                            row["Tien"] = 0;
                            row["Tien_Nt1"] = 0;
                            row["Tien1"] = 0;
                            base.LocalDetailTable.Rows.Add(row);
                        }
                    }
                    base.DetailGridBrowser.CurrentCell = base.DetailGridBrowser.FirstDisplayedCell;
                    base.DetailGridBrowser.Focus();
                }
            }
        }

        private void DetailGridBrowser_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                this.SetItemRatio();
            }
            else if (e.ColumnIndex == 2)
            {
                this.SetItemRatio();
            }
            else if (e.ColumnIndex == 9)
            {
                this.Calculate(1);
                this.Sum();
            }
            else if (e.ColumnIndex == 10)
            {
                this.Calculate(2);
                this.Sum();
            }
            else if (e.ColumnIndex == 12)
            {
                this.Calculate(3);
                this.Sum();
            }
        }

        private void DetailGridBrowser_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 2)
            {
                this.SetItemUnits();
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void GetTruePrice(object sender, EventArgs e)
        {
            if (base.txtNgay_Ct.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập ngày chứng từ!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else if (this.txtMa_Dt.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập mã đối tượng!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                object obj2 = null;
                object obj3 = 0;
                object obj4 = 0;
                object obj5 = 0;
                object obj6 = 0;
                foreach (DataRow row in base.LocalDetailTable.Rows)
                {
                    if ((row.RowState == DataRowState.Deleted) || string.IsNullOrEmpty(row["Ma_Vt"].ToString()))
                    {
                        continue;
                    }
                    obj3 = this.oMethod.GetTruePrice(AppInstance.Subsidiary, base.AppInvoiceParameters.InvoiceType, base.txtNgay_Ct.Value, this.txtMa_Dt.Value, row["Ma_Vt"], ref obj2);
                    if (this.txtMa_Tte.Value.ToString() == AppInstance.DefaultCurrency)
                    {
                        obj4 = decimal.Round((decimal) obj3, base.FCPriceDecimals);
                        obj5 = decimal.Round(((decimal) obj3) * ((decimal) row["He_So9"]), base.LCPriceDecimals);
                        obj6 = decimal.Round((decimal) obj5, base.FCPriceDecimals);
                    }
                    else
                    {
                        obj4 = decimal.Round(((decimal) obj3) / base.ExchangeRate, base.FCPriceDecimals);
                        obj5 = decimal.Round(((decimal) obj3) * ((decimal) row["He_So9"]), base.LCPriceDecimals);
                        obj6 = decimal.Round((((decimal) obj3) * ((decimal) row["He_So9"])) / base.ExchangeRate, base.FCPriceDecimals);
                    }
                    row["Stt0_B"] = obj2;
                    row["So_Luong"] = decimal.Round(((decimal) row["So_Luong9"]) * ((decimal) row["He_So9"]), base.QuantityDecimals);
                    row["Gia"] = obj3;
                    row["Gia_Nt"] = obj4;
                    row["Gia9"] = obj5;
                    row["Gia_Nt9"] = obj6;
                    this.Calculate(row, 1);
                }
                this.Sum();
            }
        }

        private void grdDetail_CellBottomLeftLeaved(object sender, EventArgs e)
        {
            if (((base.DetailGridBrowser.Rows.Count == 1) || !string.IsNullOrEmpty(((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row["Ma_Vt"].ToString())) || !string.IsNullOrEmpty(base.ActiveControl.Text))
            {
                (base.DetailGridBrowser as GridDetail).UserMoveNextCell = GridDetail.MoveNextType.NextCell;
            }
            else
            {
                this.txtNgay_GH.Focus();
                (base.DetailGridBrowser as GridDetail).UserMoveNextCell = GridDetail.MoveNextType.DeleteCurrentRow;
            }
        }

        private void grdDetail_CellRightLeaved(object sender, EventArgs e)
        {
            if (this.AddNewRow(false))
            {
                (base.DetailGridBrowser as GridDetail).UserMoveNextCell = GridDetail.MoveNextType.FirstCell;
            }
            else
            {
                (base.DetailGridBrowser as GridDetail).UserMoveNextCell = GridDetail.MoveNextType.FirstCellNextRow;
            }
        }

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormCTDHEditor));
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
            this.txtDesc_EN = new QMVnSoft.Controls.TextControl();
            this.txtDien_Giai = new QMVnSoft.Controls.TextControl();
            this.txtTen_Hd = new QMVnSoft.Controls.TextControl();
            this.txtTen_Bp = new QMVnSoft.Controls.TextControl();
            this.lblDesc_EN = new QMVnSoft.Controls.LabelControl();
            this.lblDien_Giai = new QMVnSoft.Controls.LabelControl();
            this.txtMa_Hd = new QMVnSoft.Controls.TextSearch();
            this.lblMa_Hd = new QMVnSoft.Controls.LabelControl();
            this.txtMa_Bp = new QMVnSoft.Controls.TextSearch();
            this.lblMa_Bp = new QMVnSoft.Controls.LabelControl();
            this.lblMa_Nv = new QMVnSoft.Controls.LabelControl();
            this.txtMa_Nv = new QMVnSoft.Controls.TextSearch();
            this.txtTen_Nv = new QMVnSoft.Controls.TextControl();
            this.lblNoi_GH = new QMVnSoft.Controls.LabelControl();
            this.txtNoi_GH = new QMVnSoft.Controls.TextControl();
            this.txtMa_Tte = new QMVnSoft.Controls.TextOption();
            this.txtTy_Gia = new QMVnSoft.Controls.TextNumeric();
            this.txtDia_Chi = new QMVnSoft.Controls.TextControl();
            this.txtOng_Ba = new QMVnSoft.Controls.TextControl();
            this.txtTen_Dt = new QMVnSoft.Controls.TextControl();
            this.lblMa_Tte = new QMVnSoft.Controls.LabelControl();
            this.txtMa_Dt = new QMVnSoft.Controls.TextSearch();
            this.lblDia_Chi = new QMVnSoft.Controls.LabelControl();
            this.lblOng_Ba = new QMVnSoft.Controls.LabelControl();
            this.lblMa_Dt = new QMVnSoft.Controls.LabelControl();
            this.lblPhones = new QMVnSoft.Controls.LabelControl();
            this.lblEmail = new QMVnSoft.Controls.LabelControl();
            this.txtPhones = new QMVnSoft.Controls.TextControl();
            this.txtEmail = new QMVnSoft.Controls.TextControl();
            this.txtNgay_GH = new QMVnSoft.Controls.TextDate();
            this.lblNgay_GH = new QMVnSoft.Controls.LabelControl();
            this.grdDetail = new QMVnSoft.Controls.GridDetail();
            this.Column9 = new QMVnSoft.Controls.ChildGridControls.SearchColumn();
            this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column11 = new QMVnSoft.Controls.ChildGridControls.OptionColumn();
            this.Column12 = new QMVnSoft.Controls.ChildGridControls.SearchColumn();
            this.Column13 = new QMVnSoft.Controls.ChildGridControls.SearchColumn();
            this.Column14 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column1 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column2 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column3 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column15 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column16 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column17 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column18 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column4 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.txtTTien_Nt0 = new QMVnSoft.Controls.TextNumeric();
            this.lblTTien_Nt0 = new QMVnSoft.Controls.LabelControl();
            this.lblGhi_Chu = new QMVnSoft.Controls.LabelControl();
            this.txtGhi_Chu = new QMVnSoft.Controls.TextControl();
            ((System.ComponentModel.ISupportInitialize)(this.grdDetail)).BeginInit();
            this.SuspendLayout();
            // 
            // lblPhan_Loai
            // 
            this.lblPhan_Loai.Location = new System.Drawing.Point(12, 492);
            // 
            // txtMa_Loai1
            // 
            this.txtMa_Loai1.Location = new System.Drawing.Point(99, 489);
            this.txtMa_Loai1.TabIndex = 19;
            // 
            // txtMa_Loai2
            // 
            this.txtMa_Loai2.Location = new System.Drawing.Point(327, 489);
            this.txtMa_Loai2.TabIndex = 20;
            // 
            // txtMa_Loai3
            // 
            this.txtMa_Loai3.Location = new System.Drawing.Point(555, 489);
            this.txtMa_Loai3.TabIndex = 21;
            // 
            // txtNgay_Ct
            // 
            this.txtNgay_Ct.TabIndex = 1;
            // 
            // txtNgay_Ps
            // 
            this.txtNgay_Ps.TabIndex = 0;
            // 
            // txtSo_Ct
            // 
            this.txtSo_Ct.TabIndex = 2;
            // 
            // txtDesc_EN
            // 
            this.txtDesc_EN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.txtDesc_EN.CheckTextSearched = false;
            this.txtDesc_EN.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtDesc_EN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtDesc_EN.Location = new System.Drawing.Point(487, 200);
            this.txtDesc_EN.MaxLength = 254;
            this.txtDesc_EN.Name = "txtDesc_EN";
            this.txtDesc_EN.OldValue = null;
            this.txtDesc_EN.Size = new System.Drawing.Size(295, 20);
            this.txtDesc_EN.TabIndex = 14;
            this.txtDesc_EN.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.InvoiceDescription;
            this.txtDesc_EN.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtDesc_EN.Value = ((object)(resources.GetObject("txtDesc_EN.Value")));
            // 
            // txtDien_Giai
            // 
            this.txtDien_Giai.CheckTextSearched = false;
            this.txtDien_Giai.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtDien_Giai.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtDien_Giai.Location = new System.Drawing.Point(99, 200);
            this.txtDien_Giai.MaxLength = 254;
            this.txtDien_Giai.Name = "txtDien_Giai";
            this.txtDien_Giai.OldValue = null;
            this.txtDien_Giai.Size = new System.Drawing.Size(296, 20);
            this.txtDien_Giai.TabIndex = 13;
            this.txtDien_Giai.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.InvoiceDescription;
            this.txtDien_Giai.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtDien_Giai.Value = ((object)(resources.GetObject("txtDien_Giai.Value")));
            // 
            // txtTen_Hd
            // 
            this.txtTen_Hd.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Hd.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Hd.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Hd.CheckTextSearched = false;
            this.txtTen_Hd.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Hd.Enabled = false;
            this.txtTen_Hd.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Hd.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Hd.Location = new System.Drawing.Point(223, 119);
            this.txtTen_Hd.Name = "txtTen_Hd";
            this.txtTen_Hd.OldValue = null;
            this.txtTen_Hd.Size = new System.Drawing.Size(559, 13);
            this.txtTen_Hd.TabIndex = 86;
            this.txtTen_Hd.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Hd.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Hd.Value = ((object)(resources.GetObject("txtTen_Hd.Value")));
            // 
            // txtTen_Bp
            // 
            this.txtTen_Bp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Bp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Bp.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Bp.CheckTextSearched = false;
            this.txtTen_Bp.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Bp.Enabled = false;
            this.txtTen_Bp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Bp.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Bp.Location = new System.Drawing.Point(223, 98);
            this.txtTen_Bp.Name = "txtTen_Bp";
            this.txtTen_Bp.OldValue = null;
            this.txtTen_Bp.Size = new System.Drawing.Size(559, 13);
            this.txtTen_Bp.TabIndex = 87;
            this.txtTen_Bp.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Bp.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Bp.Value = ((object)(resources.GetObject("txtTen_Bp.Value")));
            // 
            // lblDesc_EN
            // 
            this.lblDesc_EN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.lblDesc_EN.AutoSize = true;
            this.lblDesc_EN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDesc_EN.Location = new System.Drawing.Point(410, 203);
            this.lblDesc_EN.Name = "lblDesc_EN";
            this.lblDesc_EN.Size = new System.Drawing.Size(71, 14);
            this.lblDesc_EN.TabIndex = 80;
            this.lblDesc_EN.Text = "Diễn giải (EN)";
            // 
            // lblDien_Giai
            // 
            this.lblDien_Giai.AutoSize = true;
            this.lblDien_Giai.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDien_Giai.Location = new System.Drawing.Point(12, 203);
            this.lblDien_Giai.Name = "lblDien_Giai";
            this.lblDien_Giai.Size = new System.Drawing.Size(73, 14);
            this.lblDien_Giai.TabIndex = 81;
            this.lblDien_Giai.Text = "Diễn giải (VN)";
            // 
            // txtMa_Hd
            // 
            this.txtMa_Hd.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Hd.CheckTextSearched = false;
            this.txtMa_Hd.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Hd.EmptyIsValid = true;
            this.txtMa_Hd.FieldDisplay = "Ten_Hd";
            this.txtMa_Hd.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Hd.FoundIsValid = true;
            this.txtMa_Hd.Location = new System.Drawing.Point(99, 116);
            this.txtMa_Hd.MaxLength = 32;
            this.txtMa_Hd.Name = "txtMa_Hd";
            this.txtMa_Hd.OldValue = null;
            this.txtMa_Hd.Size = new System.Drawing.Size(118, 20);
            this.txtMa_Hd.TabIndex = 7;
            this.txtMa_Hd.TableName = "DMHD";
            this.txtMa_Hd.TextDisplay = this.txtTen_Hd;
            this.txtMa_Hd.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Hd.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Hd.Value = ((object)(resources.GetObject("txtMa_Hd.Value")));
            this.txtMa_Hd.Validated += new System.EventHandler(this.txtMa_Hd_Validated);
            // 
            // lblMa_Hd
            // 
            this.lblMa_Hd.AutoSize = true;
            this.lblMa_Hd.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Hd.Location = new System.Drawing.Point(12, 119);
            this.lblMa_Hd.Name = "lblMa_Hd";
            this.lblMa_Hd.Size = new System.Drawing.Size(54, 14);
            this.lblMa_Hd.TabIndex = 82;
            this.lblMa_Hd.Text = "Hợp đồng";
            // 
            // txtMa_Bp
            // 
            this.txtMa_Bp.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Bp.CheckTextSearched = false;
            this.txtMa_Bp.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Bp.EmptyIsValid = true;
            this.txtMa_Bp.FieldDisplay = "Ten_Bp";
            this.txtMa_Bp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Bp.FoundIsValid = true;
            this.txtMa_Bp.Location = new System.Drawing.Point(99, 95);
            this.txtMa_Bp.MaxLength = 32;
            this.txtMa_Bp.Name = "txtMa_Bp";
            this.txtMa_Bp.OldValue = null;
            this.txtMa_Bp.Size = new System.Drawing.Size(118, 20);
            this.txtMa_Bp.TabIndex = 6;
            this.txtMa_Bp.TableName = "DMBP";
            this.txtMa_Bp.TextDisplay = this.txtTen_Bp;
            this.txtMa_Bp.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Bp.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Bp.Value = ((object)(resources.GetObject("txtMa_Bp.Value")));
            this.txtMa_Bp.Validated += new System.EventHandler(this.txtMa_Bp_Validated);
            // 
            // lblMa_Bp
            // 
            this.lblMa_Bp.AutoSize = true;
            this.lblMa_Bp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Bp.Location = new System.Drawing.Point(12, 98);
            this.lblMa_Bp.Name = "lblMa_Bp";
            this.lblMa_Bp.Size = new System.Drawing.Size(47, 14);
            this.lblMa_Bp.TabIndex = 83;
            this.lblMa_Bp.Text = "Bộ phận";
            // 
            // lblMa_Nv
            // 
            this.lblMa_Nv.AutoSize = true;
            this.lblMa_Nv.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Nv.Location = new System.Drawing.Point(12, 77);
            this.lblMa_Nv.Name = "lblMa_Nv";
            this.lblMa_Nv.Size = new System.Drawing.Size(55, 14);
            this.lblMa_Nv.TabIndex = 84;
            this.lblMa_Nv.Text = "Nhân viên";
            // 
            // txtMa_Nv
            // 
            this.txtMa_Nv.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Nv.CheckTextSearched = false;
            this.txtMa_Nv.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Nv.FieldDisplay = "Ten_Nv";
            this.txtMa_Nv.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Nv.Location = new System.Drawing.Point(99, 74);
            this.txtMa_Nv.MaxLength = 32;
            this.txtMa_Nv.Name = "txtMa_Nv";
            this.txtMa_Nv.OldValue = null;
            this.txtMa_Nv.Size = new System.Drawing.Size(118, 20);
            this.txtMa_Nv.TabIndex = 5;
            this.txtMa_Nv.TableName = "DMNV";
            this.txtMa_Nv.TextDisplay = this.txtTen_Nv;
            this.txtMa_Nv.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Nv.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Nv.Value = ((object)(resources.GetObject("txtMa_Nv.Value")));
            // 
            // txtTen_Nv
            // 
            this.txtTen_Nv.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Nv.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Nv.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Nv.CheckTextSearched = false;
            this.txtTen_Nv.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Nv.Enabled = false;
            this.txtTen_Nv.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Nv.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Nv.Location = new System.Drawing.Point(223, 77);
            this.txtTen_Nv.Name = "txtTen_Nv";
            this.txtTen_Nv.OldValue = null;
            this.txtTen_Nv.Size = new System.Drawing.Size(559, 13);
            this.txtTen_Nv.TabIndex = 85;
            this.txtTen_Nv.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Nv.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Nv.Value = ((object)(resources.GetObject("txtTen_Nv.Value")));
            // 
            // lblNoi_GH
            // 
            this.lblNoi_GH.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.lblNoi_GH.AutoSize = true;
            this.lblNoi_GH.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNoi_GH.Location = new System.Drawing.Point(187, 450);
            this.lblNoi_GH.Name = "lblNoi_GH";
            this.lblNoi_GH.Size = new System.Drawing.Size(98, 14);
            this.lblNoi_GH.TabIndex = 81;
            this.lblNoi_GH.Text = "Địa điểm giao hàng";
            // 
            // txtNoi_GH
            // 
            this.txtNoi_GH.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtNoi_GH.CheckTextSearched = false;
            this.txtNoi_GH.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtNoi_GH.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNoi_GH.Location = new System.Drawing.Point(291, 447);
            this.txtNoi_GH.MaxLength = 254;
            this.txtNoi_GH.Name = "txtNoi_GH";
            this.txtNoi_GH.OldValue = null;
            this.txtNoi_GH.Size = new System.Drawing.Size(491, 20);
            this.txtNoi_GH.TabIndex = 17;
            this.txtNoi_GH.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.InvoiceDescription;
            this.txtNoi_GH.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtNoi_GH.Value = ((object)(resources.GetObject("txtNoi_GH.Value")));
            // 
            // txtMa_Tte
            // 
            this.txtMa_Tte.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.txtMa_Tte.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Tte.CheckTextSearched = false;
            this.txtMa_Tte.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtMa_Tte.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Tte.InputMask = "USD,VND";
            this.txtMa_Tte.Location = new System.Drawing.Point(697, 53);
            this.txtMa_Tte.Name = "txtMa_Tte";
            this.txtMa_Tte.OldValue = null;
            this.txtMa_Tte.Size = new System.Drawing.Size(28, 20);
            this.txtMa_Tte.TabIndex = 3;
            this.txtMa_Tte.Text = "USD";
            this.txtMa_Tte.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtMa_Tte.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtMa_Tte.Value = "USD";
            this.txtMa_Tte.Validated += new System.EventHandler(this.txtMa_Tte_Validated);
            // 
            // txtTy_Gia
            // 
            this.txtTy_Gia.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTy_Gia.BackColor = System.Drawing.Color.White;
            this.txtTy_Gia.DisabledBackColor = System.Drawing.Color.Empty;
            this.txtTy_Gia.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTy_Gia.ForeColor = System.Drawing.Color.Black;
            this.txtTy_Gia.Location = new System.Drawing.Point(724, 53);
            this.txtTy_Gia.Name = "txtTy_Gia";
            this.txtTy_Gia.NumericValue = new decimal(new int[] {
            0,
            0,
            0,
            0});
            this.txtTy_Gia.OldValue = null;
            this.txtTy_Gia.Size = new System.Drawing.Size(58, 20);
            this.txtTy_Gia.TabIndex = 4;
            this.txtTy_Gia.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txtTy_Gia.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.ExchangeRate;
            this.txtTy_Gia.Value = ((object)(resources.GetObject("txtTy_Gia.Value")));
            this.txtTy_Gia.Validated += new System.EventHandler(this.txtTy_Gia_Validated);
            // 
            // txtDia_Chi
            // 
            this.txtDia_Chi.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.txtDia_Chi.CheckTextSearched = false;
            this.txtDia_Chi.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtDia_Chi.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtDia_Chi.Location = new System.Drawing.Point(487, 158);
            this.txtDia_Chi.MaxLength = 128;
            this.txtDia_Chi.Name = "txtDia_Chi";
            this.txtDia_Chi.OldValue = null;
            this.txtDia_Chi.Size = new System.Drawing.Size(295, 20);
            this.txtDia_Chi.TabIndex = 10;
            this.txtDia_Chi.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtDia_Chi.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtDia_Chi.Value = ((object)(resources.GetObject("txtDia_Chi.Value")));
            // 
            // txtOng_Ba
            // 
            this.txtOng_Ba.CheckTextSearched = false;
            this.txtOng_Ba.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtOng_Ba.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtOng_Ba.Location = new System.Drawing.Point(99, 158);
            this.txtOng_Ba.MaxLength = 128;
            this.txtOng_Ba.Name = "txtOng_Ba";
            this.txtOng_Ba.OldValue = null;
            this.txtOng_Ba.Size = new System.Drawing.Size(296, 20);
            this.txtOng_Ba.TabIndex = 9;
            this.txtOng_Ba.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtOng_Ba.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtOng_Ba.Value = ((object)(resources.GetObject("txtOng_Ba.Value")));
            // 
            // txtTen_Dt
            // 
            this.txtTen_Dt.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Dt.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Dt.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Dt.CheckTextSearched = false;
            this.txtTen_Dt.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Dt.Enabled = false;
            this.txtTen_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Dt.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Dt.Location = new System.Drawing.Point(223, 140);
            this.txtTen_Dt.Name = "txtTen_Dt";
            this.txtTen_Dt.OldValue = null;
            this.txtTen_Dt.Size = new System.Drawing.Size(559, 13);
            this.txtTen_Dt.TabIndex = 97;
            this.txtTen_Dt.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Dt.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Dt.Value = ((object)(resources.GetObject("txtTen_Dt.Value")));
            // 
            // lblMa_Tte
            // 
            this.lblMa_Tte.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.lblMa_Tte.AutoSize = true;
            this.lblMa_Tte.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Tte.Location = new System.Drawing.Point(652, 56);
            this.lblMa_Tte.Name = "lblMa_Tte";
            this.lblMa_Tte.Size = new System.Drawing.Size(39, 14);
            this.lblMa_Tte.TabIndex = 93;
            this.lblMa_Tte.Text = "Tiền tệ";
            // 
            // txtMa_Dt
            // 
            this.txtMa_Dt.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Dt.CheckTextSearched = false;
            this.txtMa_Dt.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Dt.EmptyIsValid = true;
            this.txtMa_Dt.FieldDisplay = "Ten_Dt";
            this.txtMa_Dt.FirstFilter = "Is_Stop = \'1\'";
            this.txtMa_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Dt.Location = new System.Drawing.Point(99, 137);
            this.txtMa_Dt.MaxLength = 32;
            this.txtMa_Dt.Name = "txtMa_Dt";
            this.txtMa_Dt.OldValue = null;
            this.txtMa_Dt.Size = new System.Drawing.Size(118, 20);
            this.txtMa_Dt.TabIndex = 8;
            this.txtMa_Dt.TableName = "DMDT";
            this.txtMa_Dt.TextDisplay = this.txtTen_Dt;
            this.txtMa_Dt.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Dt.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Dt.Value = ((object)(resources.GetObject("txtMa_Dt.Value")));
            this.txtMa_Dt.Validated += new System.EventHandler(this.txtMa_Dt_Validated);
            // 
            // lblDia_Chi
            // 
            this.lblDia_Chi.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.lblDia_Chi.AutoSize = true;
            this.lblDia_Chi.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDia_Chi.Location = new System.Drawing.Point(441, 161);
            this.lblDia_Chi.Name = "lblDia_Chi";
            this.lblDia_Chi.Size = new System.Drawing.Size(40, 14);
            this.lblDia_Chi.TabIndex = 95;
            this.lblDia_Chi.Text = "Địa chỉ";
            // 
            // lblOng_Ba
            // 
            this.lblOng_Ba.AutoSize = true;
            this.lblOng_Ba.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblOng_Ba.Location = new System.Drawing.Point(12, 161);
            this.lblOng_Ba.Name = "lblOng_Ba";
            this.lblOng_Ba.Size = new System.Drawing.Size(42, 14);
            this.lblOng_Ba.TabIndex = 96;
            this.lblOng_Ba.Text = "Ông bà";
            // 
            // lblMa_Dt
            // 
            this.lblMa_Dt.AutoSize = true;
            this.lblMa_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Dt.Location = new System.Drawing.Point(12, 140);
            this.lblMa_Dt.Name = "lblMa_Dt";
            this.lblMa_Dt.Size = new System.Drawing.Size(55, 14);
            this.lblMa_Dt.TabIndex = 94;
            this.lblMa_Dt.Text = "Đối tượng";
            // 
            // lblPhones
            // 
            this.lblPhones.AutoSize = true;
            this.lblPhones.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblPhones.Location = new System.Drawing.Point(12, 182);
            this.lblPhones.Name = "lblPhones";
            this.lblPhones.Size = new System.Drawing.Size(55, 14);
            this.lblPhones.TabIndex = 96;
            this.lblPhones.Text = "Điện thoại";
            // 
            // lblEmail
            // 
            this.lblEmail.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.lblEmail.AutoSize = true;
            this.lblEmail.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblEmail.Location = new System.Drawing.Point(450, 182);
            this.lblEmail.Name = "lblEmail";
            this.lblEmail.Size = new System.Drawing.Size(31, 14);
            this.lblEmail.TabIndex = 95;
            this.lblEmail.Text = "Email";
            // 
            // txtPhones
            // 
            this.txtPhones.CheckTextSearched = false;
            this.txtPhones.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtPhones.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtPhones.Location = new System.Drawing.Point(99, 179);
            this.txtPhones.MaxLength = 128;
            this.txtPhones.Name = "txtPhones";
            this.txtPhones.OldValue = null;
            this.txtPhones.Size = new System.Drawing.Size(296, 20);
            this.txtPhones.TabIndex = 11;
            this.txtPhones.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtPhones.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtPhones.Value = ((object)(resources.GetObject("txtPhones.Value")));
            // 
            // txtEmail
            // 
            this.txtEmail.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.txtEmail.CheckTextSearched = false;
            this.txtEmail.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtEmail.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtEmail.Location = new System.Drawing.Point(487, 179);
            this.txtEmail.MaxLength = 128;
            this.txtEmail.Name = "txtEmail";
            this.txtEmail.OldValue = null;
            this.txtEmail.Size = new System.Drawing.Size(295, 20);
            this.txtEmail.TabIndex = 12;
            this.txtEmail.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtEmail.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtEmail.Value = ((object)(resources.GetObject("txtEmail.Value")));
            // 
            // txtNgay_GH
            // 
            this.txtNgay_GH.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.txtNgay_GH.DateTimeFormat  = QMVnSoft.Controls.TextDate.DateTimeFormatType.Date;
            this.txtNgay_GH.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNgay_GH.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite;
            this.txtNgay_GH.Location = new System.Drawing.Point(99, 447);
            this.txtNgay_GH.Mask = "00/00/0000";
            this.txtNgay_GH.Name = "txtNgay_GH";
            this.txtNgay_GH.OldValue = null;
            this.txtNgay_GH.Size = new System.Drawing.Size(79, 20);
            this.txtNgay_GH.TabIndex = 16;
            this.txtNgay_GH.Value = ((object)(resources.GetObject("txtNgay_GH.Value")));
            // 
            // lblNgay_GH
            // 
            this.lblNgay_GH.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.lblNgay_GH.AutoSize = true;
            this.lblNgay_GH.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNgay_GH.Location = new System.Drawing.Point(12, 450);
            this.lblNgay_GH.Name = "lblNgay_GH";
            this.lblNgay_GH.Size = new System.Drawing.Size(82, 14);
            this.lblNgay_GH.TabIndex = 99;
            this.lblNgay_GH.Text = "Ngày giao hàng";
            // 
            // grdDetail
            // 
            this.grdDetail.AllowUserToAddRows = false;
            this.grdDetail.AllowUserToDeleteRows = false;
            this.grdDetail.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.grdDetail.CheckAutoSize = true;
            this.grdDetail.CheckColor = false;
            this.grdDetail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdDetail.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.Column9,
            this.Column10,
            this.Column11,
            this.Column12,
            this.Column13,
            this.Column14,
            this.Column1,
            this.Column2,
            this.Column3,
            this.Column15,
            this.Column16,
            this.Column17,
            this.Column18,
            this.Column4});
            this.grdDetail.Font = new System.Drawing.Font("Arial", 8.25F);
            this.grdDetail.Location = new System.Drawing.Point(0, 226);
            this.grdDetail.Name = "grdDetail";
            this.grdDetail.Size = new System.Drawing.Size(794, 215);
            this.grdDetail.TabIndex = 15;
            this.grdDetail.CellRightLeaved += new System.EventHandler(this.grdDetail_CellRightLeaved);
            this.grdDetail.CellBottomLeftLeaved += new System.EventHandler(this.grdDetail_CellBottomLeftLeaved);
            // 
            // Column9
            // 
            this.Column9.DataPropertyName = "Ma_Vt";
            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column9.DefaultCellStyle = dataGridViewCellStyle1;
            this.Column9.DestinationFields = "Ten_Vt, Dvt";
            this.Column9.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column9.FirstFilter = "Is_Stop = \'1\'";
            this.Column9.HeaderText = "Mã vật tư";
            this.Column9.Name = "Column9";
            this.Column9.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column9.SourceFields = "Ten_Vt, Dvt";
            this.Column9.TableName = "DMVT";
            this.Column9.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.Column9.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.Column9.Width = 45;
            // 
            // Column10
            // 
            this.Column10.DataPropertyName = "Ten_Vt";
            this.Column10.HeaderText = "Tên vật tư";
            this.Column10.Name = "Column10";
            this.Column10.Width = 110;
            // 
            // Column11
            // 
            this.Column11.DataPropertyName = "Dvt";
            dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column11.DefaultCellStyle = dataGridViewCellStyle2;
            this.Column11.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column11.HeaderText = "Đvt";
            this.Column11.Name = "Column11";
            this.Column11.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column11.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.Column11.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.Column11.Width = 30;
            // 
            // Column12
            // 
            this.Column12.DataPropertyName = "Ma_Bp";
            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column12.DefaultCellStyle = dataGridViewCellStyle3;
            this.Column12.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column12.HeaderText = "Bộ phận";
            this.Column12.Name = "Column12";
            this.Column12.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column12.TableName = "DMBP";
            this.Column12.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.Column12.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.Column12.Width = 45;
            // 
            // Column13
            // 
            this.Column13.DataPropertyName = "Ma_Hd";
            dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column13.DefaultCellStyle = dataGridViewCellStyle4;
            this.Column13.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column13.HeaderText = "Hợp đồng";
            this.Column13.Name = "Column13";
            this.Column13.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column13.TableName = "DMHD";
            this.Column13.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.Column13.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.Column13.Width = 45;
            // 
            // Column14
            // 
            this.Column14.DataPropertyName = "Ghi_Chu";
            this.Column14.HeaderText = "Ghi chú";
            this.Column14.Name = "Column14";
            this.Column14.Width = 106;
            // 
            // Column1
            // 
            this.Column1.DataPropertyName = "So_Luong0";
            dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column1.DefaultCellStyle = dataGridViewCellStyle5;
            this.Column1.HeaderText = "Yêu cầu";
            this.Column1.Name = "Column1";
            this.Column1.ReadOnly = true;
            this.Column1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column1.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.Quantity;
            this.Column1.Width = 45;
            // 
            // Column2
            // 
            this.Column2.DataPropertyName = "So_Luong1";
            dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column2.DefaultCellStyle = dataGridViewCellStyle6;
            this.Column2.HeaderText = "Thực hiện";
            this.Column2.Name = "Column2";
            this.Column2.ReadOnly = true;
            this.Column2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column2.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.Quantity;
            this.Column2.Width = 45;
            // 
            // Column3
            // 
            this.Column3.DataPropertyName = "So_Luong2";
            dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column3.DefaultCellStyle = dataGridViewCellStyle7;
            this.Column3.HeaderText = "Còn lại";
            this.Column3.Name = "Column3";
            this.Column3.ReadOnly = true;
            this.Column3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column3.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.Quantity;
            this.Column3.Width = 45;
            // 
            // Column15
            // 
            this.Column15.DataPropertyName = "So_Luong9";
            dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column15.DefaultCellStyle = dataGridViewCellStyle8;
            this.Column15.HeaderText = "Đặt hàng";
            this.Column15.Name = "Column15";
            this.Column15.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column15.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.Quantity;
            this.Column15.Width = 45;
            // 
            // Column16
            // 
            this.Column16.DataPropertyName = "Gia_Nt9";
            dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column16.DefaultCellStyle = dataGridViewCellStyle9;
            this.Column16.HeaderText = "Đơn giá";
            this.Column16.Name = "Column16";
            this.Column16.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column16.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.ForeignPrice;
            this.Column16.Width = 50;
            // 
            // Column17
            // 
            this.Column17.DataPropertyName = "Tien_Nt";
            dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column17.DefaultCellStyle = dataGridViewCellStyle10;
            this.Column17.HeaderText = "Thành tiền";
            this.Column17.Name = "Column17";
            this.Column17.ReadOnly = true;
            this.Column17.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column17.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.ForeignAmount;
            this.Column17.Width = 60;
            // 
            // Column18
            // 
            this.Column18.DataPropertyName = "Tien_Nt1";
            dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column18.DefaultCellStyle = dataGridViewCellStyle11;
            this.Column18.HeaderText = "Chi phí";
            this.Column18.Name = "Column18";
            this.Column18.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column18.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.ForeignAmount;
            this.Column18.Width = 60;
            // 
            // Column4
            // 
            this.Column4.DataPropertyName = "Marked";
            this.Column4.HeaderText = "";
            this.Column4.Name = "Column4";
            this.Column4.Resizable = System.Windows.Forms.DataGridViewTriState.False;
            this.Column4.Width = 20;
            // 
            // txtTTien_Nt0
            // 
            this.txtTTien_Nt0.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTTien_Nt0.BackColor = System.Drawing.Color.White;
            this.txtTTien_Nt0.Enabled = false;
            this.txtTTien_Nt0.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTTien_Nt0.ForeColor = System.Drawing.Color.Black;
            this.txtTTien_Nt0.Location = new System.Drawing.Point(674, 468);
            this.txtTTien_Nt0.Name = "txtTTien_Nt0";
            this.txtTTien_Nt0.NumericValue = new decimal(new int[] {
            0,
            0,
            0,
            0});
            this.txtTTien_Nt0.OldValue = null;
            this.txtTTien_Nt0.Size = new System.Drawing.Size(108, 20);
            this.txtTTien_Nt0.TabIndex = 102;
            this.txtTTien_Nt0.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txtTTien_Nt0.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.ForeignAmount;
            this.txtTTien_Nt0.Value = ((object)(resources.GetObject("txtTTien_Nt0.Value")));
            // 
            // lblTTien_Nt0
            // 
            this.lblTTien_Nt0.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.lblTTien_Nt0.AutoSize = true;
            this.lblTTien_Nt0.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTTien_Nt0.Location = new System.Drawing.Point(617, 472);
            this.lblTTien_Nt0.Name = "lblTTien_Nt0";
            this.lblTTien_Nt0.Size = new System.Drawing.Size(51, 14);
            this.lblTTien_Nt0.TabIndex = 101;
            this.lblTTien_Nt0.Text = "Tổng tiền";
            // 
            // lblGhi_Chu
            // 
            this.lblGhi_Chu.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.lblGhi_Chu.AutoSize = true;
            this.lblGhi_Chu.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblGhi_Chu.Location = new System.Drawing.Point(12, 471);
            this.lblGhi_Chu.Name = "lblGhi_Chu";
            this.lblGhi_Chu.Size = new System.Drawing.Size(44, 14);
            this.lblGhi_Chu.TabIndex = 81;
            this.lblGhi_Chu.Text = "Ghi chú";
            // 
            // txtGhi_Chu
            // 
            this.txtGhi_Chu.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtGhi_Chu.CheckTextSearched = false;
            this.txtGhi_Chu.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtGhi_Chu.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtGhi_Chu.Location = new System.Drawing.Point(99, 468);
            this.txtGhi_Chu.Name = "txtGhi_Chu";
            this.txtGhi_Chu.OldValue = null;
            this.txtGhi_Chu.Size = new System.Drawing.Size(455, 20);
            this.txtGhi_Chu.TabIndex = 18;
            this.txtGhi_Chu.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtGhi_Chu.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtGhi_Chu.Value = ((object)(resources.GetObject("txtGhi_Chu.Value")));
            // 
            // FormCTDHEditor
            // 
            this.ClientSize = new System.Drawing.Size(794, 534);
            this.Controls.Add(this.txtTTien_Nt0);
            this.Controls.Add(this.lblTTien_Nt0);
            this.Controls.Add(this.grdDetail);
            this.Controls.Add(this.txtNgay_GH);
            this.Controls.Add(this.lblNgay_GH);
            this.Controls.Add(this.txtMa_Tte);
            this.Controls.Add(this.txtTy_Gia);
            this.Controls.Add(this.txtEmail);
            this.Controls.Add(this.txtPhones);
            this.Controls.Add(this.txtDia_Chi);
            this.Controls.Add(this.txtOng_Ba);
            this.Controls.Add(this.txtTen_Dt);
            this.Controls.Add(this.lblMa_Tte);
            this.Controls.Add(this.lblEmail);
            this.Controls.Add(this.txtMa_Dt);
            this.Controls.Add(this.lblPhones);
            this.Controls.Add(this.lblDia_Chi);
            this.Controls.Add(this.lblOng_Ba);
            this.Controls.Add(this.lblMa_Dt);
            this.Controls.Add(this.txtDesc_EN);
            this.Controls.Add(this.txtNoi_GH);
            this.Controls.Add(this.txtGhi_Chu);
            this.Controls.Add(this.txtDien_Giai);
            this.Controls.Add(this.txtTen_Nv);
            this.Controls.Add(this.txtTen_Hd);
            this.Controls.Add(this.txtTen_Bp);
            this.Controls.Add(this.lblDesc_EN);
            this.Controls.Add(this.txtMa_Nv);
            this.Controls.Add(this.lblNoi_GH);
            this.Controls.Add(this.lblGhi_Chu);
            this.Controls.Add(this.lblMa_Nv);
            this.Controls.Add(this.lblDien_Giai);
            this.Controls.Add(this.txtMa_Hd);
            this.Controls.Add(this.lblMa_Hd);
            this.Controls.Add(this.txtMa_Bp);
            this.Controls.Add(this.lblMa_Bp);
            this.Name = "FormCTDHEditor";
            this.Controls.SetChildIndex(this.lblPhan_Loai, 0);
            this.Controls.SetChildIndex(this.txtSo_Ct, 0);
            this.Controls.SetChildIndex(this.txtNgay_Ps, 0);
            this.Controls.SetChildIndex(this.txtNgay_Ct, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai1, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai2, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai3, 0);
            this.Controls.SetChildIndex(this.lblMa_Bp, 0);
            this.Controls.SetChildIndex(this.txtMa_Bp, 0);
            this.Controls.SetChildIndex(this.lblMa_Hd, 0);
            this.Controls.SetChildIndex(this.txtMa_Hd, 0);
            this.Controls.SetChildIndex(this.lblDien_Giai, 0);
            this.Controls.SetChildIndex(this.lblMa_Nv, 0);
            this.Controls.SetChildIndex(this.lblGhi_Chu, 0);
            this.Controls.SetChildIndex(this.lblNoi_GH, 0);
            this.Controls.SetChildIndex(this.txtMa_Nv, 0);
            this.Controls.SetChildIndex(this.lblDesc_EN, 0);
            this.Controls.SetChildIndex(this.txtTen_Bp, 0);
            this.Controls.SetChildIndex(this.txtTen_Hd, 0);
            this.Controls.SetChildIndex(this.txtTen_Nv, 0);
            this.Controls.SetChildIndex(this.txtDien_Giai, 0);
            this.Controls.SetChildIndex(this.txtGhi_Chu, 0);
            this.Controls.SetChildIndex(this.txtNoi_GH, 0);
            this.Controls.SetChildIndex(this.txtDesc_EN, 0);
            this.Controls.SetChildIndex(this.lblMa_Dt, 0);
            this.Controls.SetChildIndex(this.lblOng_Ba, 0);
            this.Controls.SetChildIndex(this.lblDia_Chi, 0);
            this.Controls.SetChildIndex(this.lblPhones, 0);
            this.Controls.SetChildIndex(this.txtMa_Dt, 0);
            this.Controls.SetChildIndex(this.lblEmail, 0);
            this.Controls.SetChildIndex(this.lblMa_Tte, 0);
            this.Controls.SetChildIndex(this.txtTen_Dt, 0);
            this.Controls.SetChildIndex(this.txtOng_Ba, 0);
            this.Controls.SetChildIndex(this.txtDia_Chi, 0);
            this.Controls.SetChildIndex(this.txtPhones, 0);
            this.Controls.SetChildIndex(this.txtEmail, 0);
            this.Controls.SetChildIndex(this.txtTy_Gia, 0);
            this.Controls.SetChildIndex(this.txtMa_Tte, 0);
            this.Controls.SetChildIndex(this.lblNgay_GH, 0);
            this.Controls.SetChildIndex(this.txtNgay_GH, 0);
            this.Controls.SetChildIndex(this.grdDetail, 0);
            this.Controls.SetChildIndex(this.lblTTien_Nt0, 0);
            this.Controls.SetChildIndex(this.txtTTien_Nt0, 0);
            ((System.ComponentModel.ISupportInitialize)(this.grdDetail)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        internal override void OnAdd()
        {
            object obj2 = base.LocalMasterRow["So_Ct"];
            base.LocalMasterRow = base.MakeMasterRow();
            base.LocalMasterRow["Nh_Ct"] = base.AppInvoiceParameters.InvoiceType;
            base.LocalMasterRow["So_Ct"] = this.oMethod.Cong_So_Ct(AppInstance.Subsidiary, base.InvoiceCode, base.LocalMasterRow["Ngay_Ct"], obj2);
            base.LocalMasterRow["Ma_Tte"] = AppInstance.DefaultCurrency;
            base.LocalMasterRow["Ty_Gia"] = 1;
            base.LocalMasterRow["Ty_Gia_Ht"] = 1;
            base.LocalMasterRow["TTien_Nt0"] = 0;
            base.LocalMasterRow["TTien0"] = 0;
            base.LocalMasterRow["TTien_Nt"] = 0;
            base.LocalMasterRow["TTien"] = 0;
            base.LocalMasterRow["TTien_Nt1"] = 0;
            base.LocalMasterRow["TTien1"] = 0;
            base.MakeDetailTable();
            base.LocalDetailTable.Rows[0]["Stt_Nv"] = 1;
            base.LocalDetailTable.Rows[0]["He_So9"] = 1;
            base.LocalDetailTable.Rows[0]["So_Luong9"] = 0;
            base.LocalDetailTable.Rows[0]["Gia_Nt9"] = 0;
            base.LocalDetailTable.Rows[0]["Gia9"] = 0;
            base.LocalDetailTable.Rows[0]["So_Luong"] = 0;
            base.LocalDetailTable.Rows[0]["Gia_Nt"] = 0;
            base.LocalDetailTable.Rows[0]["Gia"] = 0;
            base.LocalDetailTable.Rows[0]["Tien_Nt"] = 0;
            base.LocalDetailTable.Rows[0]["Tien"] = 0;
            base.LocalDetailTable.Rows[0]["Tien_Nt1"] = 0;
            base.LocalDetailTable.Rows[0]["Tien1"] = 0;
            if (base.AppInvoiceParameters.AllowDepartmentControl != 1)
            {
                base.LocalMasterRow["Ma_Bp"] = DBNull.Value;
                base.LocalMasterRow["Ten_Bp"] = DBNull.Value;
            }
            if (base.AppInvoiceParameters.AllowContractControl != 1)
            {
                base.LocalMasterRow["Ma_Hd"] = DBNull.Value;
                base.LocalMasterRow["Ten_Hd"] = DBNull.Value;
            }
            base.OnAdd();
        }

        internal override void OnCopy()
        {
            object obj2 = base.LocalMasterRow["So_Ct"];
            base.LocalMasterRow["So_Ct"] = this.oMethod.Cong_So_Ct(AppInstance.Subsidiary, base.InvoiceCode, base.LocalMasterRow["Ngay_Ct"], obj2);
            base.OnCopy();
        }

        internal override void OnResetControls()
        {
            base.DetailGridBrowser = this.grdDetail;
            int num = 0;
            if (base.AppInvoiceParameters.AllowDepartmentControl != 1)
            {
                num += this.txtMa_Hd.Top - this.txtMa_Bp.Top;
                this.lblMa_Bp.Visible = false;
                this.txtMa_Bp.Visible = false;
                this.txtTen_Bp.Visible = false;
            }
            if (base.AppInvoiceParameters.AllowContractControl != 1)
            {
                num += this.txtMa_Dt.Top - this.txtMa_Hd.Top;
                this.lblMa_Hd.Visible = false;
                this.txtMa_Hd.Visible = false;
                this.txtTen_Hd.Visible = false;
            }
            if (num != 0)
            {
                if (base.AppInvoiceParameters.AllowContractControl == 1)
                {
                    this.lblMa_Hd.Top -= num;
                    this.txtMa_Hd.Top -= num;
                    this.txtTen_Hd.Top -= num;
                }
                this.lblMa_Dt.Top -= num;
                this.txtMa_Dt.Top -= num;
                this.txtTen_Dt.Top -= num;
                this.lblOng_Ba.Top -= num;
                this.txtOng_Ba.Top -= num;
                this.lblDia_Chi.Top -= num;
                this.txtDia_Chi.Top -= num;
                this.lblPhones.Top -= num;
                this.txtPhones.Top -= num;
                this.lblEmail.Top -= num;
                this.txtEmail.Top -= num;
                this.lblDien_Giai.Top -= num;
                this.txtDien_Giai.Top -= num;
                this.lblDesc_EN.Top -= num;
                this.txtDesc_EN.Top -= num;
                this.grdDetail.Top -= num;
                this.grdDetail.Height += num;
            }
            if (!base.AppInvoiceParameters.BilingualUsed)
            {
                this.lblDesc_EN.Visible = false;
                this.txtDesc_EN.Visible = false;
                this.txtDien_Giai.Width = (this.txtDesc_EN.Left + this.txtDesc_EN.Width) - this.txtDien_Giai.Left;
                this.txtDien_Giai.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            }
            if (base.AppInvoiceParameters.AllowDepartmentControl != 2)
            {
                base.DetailGridBrowser.Columns[3].Visible = false;
            }
            if (base.AppInvoiceParameters.AllowContractControl != 2)
            {
                base.DetailGridBrowser.Columns[4].Visible = false;
            }
            if (base.AppInvoiceParameters.AllowExpensesControl)
            {
                base.DetailGridBrowser.Columns[12].Visible = false;
            }
            if (base.AppInvoiceParameters.FreeFields <= 0)
            {
                num = base.txtMa_Loai1.Top - this.txtGhi_Chu.Top;
                this.lblGhi_Chu.Top += num;
                this.txtGhi_Chu.Top += num;
                this.lblNgay_GH.Top += num;
                this.txtNgay_GH.Top += num;
                this.lblNoi_GH.Top += num;
                this.txtNoi_GH.Top += num;
                this.lblTTien_Nt0.Top += num;
                this.txtTTien_Nt0.Top += num;
                this.grdDetail.Height += num;
            }
            if (!this.FormRequirement)
            {
                base.DetailGridBrowser.Columns[6].Visible = false;
                base.DetailGridBrowser.Columns[7].Visible = false;
                base.DetailGridBrowser.Columns[8].Visible = false;
                base.DetailGridBrowser.Columns[13].Visible = false;
            }
            else
            {
                base.DetailGridBrowser.Columns[0].ReadOnly = true;
                base.DetailGridBrowser.Columns[2].ReadOnly = true;
                base.DetailGridBrowser.Columns[3].ReadOnly = true;
                base.DetailGridBrowser.Columns[4].ReadOnly = true;
            }
            base.OnResetControls();
        }

        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            if (this.txtOng_Ba != null)
            {
                int num = base.ClientSize.Width - 0xcb;
                this.txtOng_Ba.Width = num / 2;
                this.txtDia_Chi.Left = (this.txtOng_Ba.Left + this.txtOng_Ba.Width) + 0x5c;
                this.txtDia_Chi.Width = num - this.txtOng_Ba.Width;
                this.lblDia_Chi.Left = (this.txtDia_Chi.Left - this.lblDia_Chi.Width) - 6;
                this.txtPhones.Width = this.txtOng_Ba.Width;
                this.txtEmail.Left = this.txtDia_Chi.Left;
                this.txtEmail.Width = this.txtDia_Chi.Width;
                this.lblEmail.Left = (this.txtEmail.Left - this.lblEmail.Width) - 6;
                if ((base.AppInvoiceParameters != null) && base.AppInvoiceParameters.BilingualUsed)
                {
                    this.txtDien_Giai.Width = this.txtOng_Ba.Width;
                    this.txtDesc_EN.Left = this.txtDia_Chi.Left;
                    this.txtDesc_EN.Width = this.txtDia_Chi.Width;
                    this.lblDesc_EN.Left = (this.txtDesc_EN.Left - this.lblDesc_EN.Width) - 6;
                }
            }
        }

        protected override bool OnSave()
        {
            if (base.txtNgay_Ps.Value == DBNull.Value)
            {
                MessageBox.Show("Chưa nhập ngày phát sinh!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (base.txtNgay_Ct.Value == DBNull.Value)
            {
                MessageBox.Show("Chưa nhập ngày chứng từ!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (((DateTime) base.txtNgay_Ct.Value) < AppInstance.OpeningDateOfSubEnterprice)
            {
                MessageBox.Show("Ngày chứng từ phải từ ngày " + AppInstance.OpeningDateOfSubEnterprice.ToShortDateString(), AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (((DateTime) base.txtNgay_Ct.Value) <= AppInstance.EndingDateOfSubEnterprice)
            {
                MessageBox.Show("Ngày chứng từ phải từ ngày " + AppInstance.EndingDateOfSubEnterprice.AddDays(1.0).ToShortDateString(), AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (!base.CheckNewRow)
            {
                int num = this.oMethod.CheckInvoiceStatus(AppInstance.Subsidiary, AppInstance.UserName, base.SavedMasterOrder);
                switch (num)
                {
                    case 9:
                    case 7:
                        break;

                    default:
                        if ((base.AppInvoiceParameters.AllowPostInvoice && base.AppInvoiceParameters.AllowLockInvoice) || ((num != 6) && (num != 5)))
                        {
                            if (num == 8)
                            {
                                base.AppInvoiceParameters.ShowInvoiceUsed(base.SavedMasterOrder, base.AppInvoiceParameters.StatusMessage(num));
                                return false;
                            }
                            goto Label_0178;
                        }
                        break;
                }
                MessageBox.Show(base.AppInvoiceParameters.StatusMessage(num), AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
        Label_0178:
            if (this.oMethod.NumberExisted(AppInstance.Subsidiary, base.CheckNewRow, base.SavedMasterOrder, base.InvoiceCode, base.txtNgay_Ct.Value, base.txtSo_Ct.Value) && (MessageBox.Show("Số chứng từ đã tồn tại. C\x00f3 tiếp tục không?", AppInstance.SoftwareName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No))
            {
                if (MessageBox.Show("C\x00f3 muốn tự động tạo số chứng từ không?", AppInstance.SoftwareName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return false;
                }
                object obj2 = base.txtSo_Ct.Value;
                base.txtSo_Ct.Value = this.oMethod.Cong_So_Ct(AppInstance.Subsidiary, base.InvoiceCode, base.LocalMasterRow["Ngay_Ct"], obj2);
            }
            base.DetailGridBrowser.EndEdit();
            base.LocalMasterRow["Ngay_Ps"] = base.txtNgay_Ps.Value;
            base.LocalMasterRow["Ngay_Ct"] = base.txtNgay_Ct.Value;
            base.LocalMasterRow["So_Ct"] = base.txtSo_Ct.Value;
            base.LocalMasterRow["Ma_Tte"] = this.txtMa_Tte.Value;
            base.LocalMasterRow["Ty_Gia"] = this.txtTy_Gia.Value;
            base.LocalMasterRow["Ty_Gia_Ht"] = base.ExchangeRate;
            base.LocalMasterRow["Ma_Nv"] = this.txtMa_Nv.Value;
            base.LocalMasterRow["Ten_Nv"] = this.txtTen_Nv.Value;
            base.LocalMasterRow["Ma_Bp"] = this.txtMa_Bp.Value;
            base.LocalMasterRow["Ten_Bp"] = this.txtTen_Bp.Value;
            base.LocalMasterRow["Ma_Hd"] = this.txtMa_Hd.Value;
            base.LocalMasterRow["Ten_Hd"] = this.txtTen_Hd.Value;
            base.LocalMasterRow["Ma_Dt"] = this.txtMa_Dt.Value;
            base.LocalMasterRow["Ten_Dt"] = this.txtTen_Dt.Value;
            base.LocalMasterRow["Ong_Ba"] = this.txtOng_Ba.Value;
            base.LocalMasterRow["Dia_Chi"] = this.txtDia_Chi.Value;
            base.LocalMasterRow["Phones"] = this.txtPhones.Value;
            base.LocalMasterRow["Email"] = this.txtEmail.Value;
            base.LocalMasterRow["Dien_Giai"] = this.txtDien_Giai.Value;
            base.LocalMasterRow["Desc_EN"] = this.txtDesc_EN.Value;
            base.LocalMasterRow["Ghi_Chu"] = this.txtGhi_Chu.Value;
            base.LocalMasterRow["Ngay_GH"] = this.txtNgay_GH.Value;
            base.LocalMasterRow["Noi_GH"] = this.txtNoi_GH.Value;
            base.LocalMasterRow["TTien_Nt0"] = this.txtTTien_Nt0.Value;
            base.LocalMasterRow["Ma_Loai1"] = base.txtMa_Loai1.Value;
            base.LocalMasterRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            base.LocalMasterRow["Ma_Loai3"] = base.txtMa_Loai3.Value;
            bool flag = true;
            if (this.oMethod.Save(base.AppInvoiceParameters.InvoiceHistory, base.CheckNewRow, AppInstance.Subsidiary, AppInstance.UserName, base.LocalMasterRow, base.LocalDetailTable, ref flag))
            {
                return base.OnSave();
            }
            if (!flag)
            {
                MessageBox.Show("Đơn hàng đã thực hiện qu\x00e1 yêu cầu mua hàng!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            return false;
        }

        internal override void OnShow()
        {
            base.OnShow();
            this.txtMa_Tte.Value = base.LocalMasterRow["Ma_Tte"];
            this.txtTy_Gia.Value = base.LocalMasterRow["Ty_Gia"];
            this.txtMa_Nv.Value = base.LocalMasterRow["Ma_Nv"];
            this.txtTen_Nv.Value = base.LocalMasterRow["Ten_Nv"];
            this.txtMa_Bp.Value = base.LocalMasterRow["Ma_Bp"];
            this.txtTen_Bp.Value = base.LocalMasterRow["Ten_Bp"];
            this.txtMa_Hd.Value = base.LocalMasterRow["Ma_Hd"];
            this.txtTen_Hd.Value = base.LocalMasterRow["Ten_Hd"];
            this.txtMa_Dt.Value = base.LocalMasterRow["Ma_Dt"];
            this.txtTen_Dt.Value = base.LocalMasterRow["Ten_Dt"];
            this.txtOng_Ba.Value = base.LocalMasterRow["Ong_Ba"];
            this.txtDia_Chi.Value = base.LocalMasterRow["Dia_Chi"];
            this.txtPhones.Value = base.LocalMasterRow["Phones"];
            this.txtEmail.Value = base.LocalMasterRow["Email"];
            this.txtDien_Giai.Value = base.LocalMasterRow["Dien_Giai"];
            this.txtDesc_EN.Value = base.LocalMasterRow["Desc_EN"];
            this.txtGhi_Chu.Value = base.LocalMasterRow["Ghi_Chu"];
            this.txtNgay_GH.Value = base.LocalMasterRow["Ngay_GH"];
            this.txtNoi_GH.Value = base.LocalMasterRow["Noi_GH"];
            this.txtTTien_Nt0.Value = base.LocalMasterRow["TTien_Nt0"];
        }

        private void RequireOrder(DataRow po_RequireRow)
        {
            base.LocalMasterRow = this.oMethod.GetMasterDataRow("AppSOFT2009");
            base.LocalDetailDataSet = this.oMethod.GetDetailDataSet("AppSOFT2009");
            DataColumn column = new DataColumn("So_Luong0", typeof(decimal));
            base.LocalDetailTable.Columns.Add(column);
            column = new DataColumn("So_Luong1", typeof(decimal));
            base.LocalDetailTable.Columns.Add(column);
            column = new DataColumn("So_Luong2", typeof(decimal));
            base.LocalDetailTable.Columns.Add(column);
            column = new DataColumn("Marked", typeof(bool));
            base.LocalDetailTable.Columns.Add(column);
            this.OnAdd();
            base.LocalMasterRow["Ngay_Ps"] = DateTime.Today;
            base.LocalMasterRow["Ngay_Ct"] = DateTime.Today;
            base.LocalMasterRow["Ngay_GH"] = po_RequireRow["Ngay_YC"];
            base.LocalMasterRow["Ma_Nv"] = po_RequireRow["Ma_NN"];
            base.LocalMasterRow["Ten_Nv"] = po_RequireRow["Ten_NN"];
            base.LocalMasterRow["Ma_Bp"] = po_RequireRow["Ma_Bp"];
            base.LocalMasterRow["Ten_Bp"] = po_RequireRow["Ten_Bp"];
            base.LocalMasterRow["Ma_Hd"] = po_RequireRow["Ma_Hd"];
            base.LocalMasterRow["Ten_Hd"] = po_RequireRow["Ten_Hd"];
            base.LocalMasterRow["Dien_Giai"] = po_RequireRow["Dien_Giai"];
            base.LocalMasterRow["Desc_EN"] = po_RequireRow["Desc_EN"];
            if (!string.IsNullOrEmpty(po_RequireRow["Ma_Hd"].ToString()))
            {
                DataRow row = AppDataAccess.SelectDataRow(false, "DMHD", "Ma_Hd", po_RequireRow["Ma_Hd"].ToString(), null);
                if (!string.IsNullOrEmpty(row["Ma_Dt"].ToString()))
                {
                    row = AppDataAccess.SelectDataRow(false, "DMDT", "Ma_Dt", row["Ma_Dt"].ToString(), null);
                    base.LocalMasterRow["Ma_Dt"] = row["Ma_Dt"];
                    base.LocalMasterRow["Ten_Dt"] = row["Ten_Dt"];
                    base.LocalMasterRow["Ong_Ba"] = row["Doi_Tac"];
                    base.LocalMasterRow["Dia_Chi"] = row["Dia_Chi"];
                    base.LocalMasterRow["Phones"] = row["Phones"];
                    base.LocalMasterRow["Email"] = row["Email"];
                }
            }
            int num = 0;
            base.LocalDetailTable.Rows.Clear();
            foreach (DataRow row3 in this.oMethod.GetDetailRequire(po_RequireRow["Stt"]).Rows)
            {
                if (row3.RowState != DataRowState.Deleted)
                {
                    num++;
                    DataRow row2 = base.MakeDetailRow();
                    row2["Stt0_D"] = row3["Stt0_D"];
                    row2["Stt_Nv"] = num;
                    row2["Ma_Vt"] = row3["Ma_Vt"];
                    row2["Ten_Vt"] = row3["Ten_Vt"];
                    row2["Dvt"] = row3["Dvt"];
                    row2["Ghi_Chu"] = row3["Ghi_Chu"];
                    row2["He_So9"] = row3["He_So9"];
                    row2["Ma_Bp"] = row3["Ma_Bp"];
                    row2["Ma_Hd"] = row3["Ma_Hd"];
                    row2["So_Luong0"] = row3["So_Luong0"];
                    row2["So_Luong1"] = row3["So_Luong1"];
                    row2["So_Luong2"] = row3["So_Luong2"];
                    row2["So_Luong9"] = 0;
                    row2["Gia_Nt9"] = 0;
                    row2["Gia9"] = 0;
                    row2["So_Luong"] = 0;
                    row2["Gia_Nt"] = 0;
                    row2["Gia"] = 0;
                    row2["Tien_Nt"] = 0;
                    row2["Tien"] = 0;
                    row2["Tien_Nt1"] = 0;
                    row2["Tien1"] = 0;
                    row2["Marked"] = false;
                    base.LocalDetailTable.Rows.Add(row2);
                }
            }
        }

        private void SetFunctions()
        {
            ToolStripMenuItem item = new ToolStripMenuItem();
            item.AutoSize = true;
            item.Text = "X\x00e1c định giá";
            item.Click += new EventHandler(this.GetTruePrice);
            if (this.FormRequirement)
            {
                base.ToolStripFunctions = new ToolStripItem[] { item };
            }
            else
            {
                ToolStripMenuItem item2 = new ToolStripMenuItem();
                item2.AutoSize = true;
                item2.Text = "Chọn báo giá";
                item2.Click += new EventHandler(this.ChooseQuotation);
                ToolStripMenuItem item3 = new ToolStripMenuItem();
                item3.AutoSize = true;
                item3.Text = "Chọn yêu cầu mua hàng";
                item3.Click += new EventHandler(this.ChooseRequires);
                base.ToolStripFunctions = new ToolStripItem[] { item2, new ToolStripSeparator(), item3, new ToolStripSeparator(), item };
            }
        }

        private void SetItemRatio()
        {
            if (!this.FormRequirement)
            {
                DataRow row = ((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row;
                DataRow row2 = AppDataAccess.SelectDataRow(false, "DMVT", "Ma_Vt", row["Ma_Vt"].ToString(), null);
                if (row2 != null)
                {
                    if (row["Dvt"].Equals(row2["Dvt"]))
                    {
                        row["He_So9"] = 1;
                    }
                    else if (row["Dvt"].Equals(row2["Dvt0"]))
                    {
                        row["He_So9"] = row2["He_So0"];
                    }
                    else if (row["Dvt"].Equals(row2["Dvt1"]))
                    {
                        row["He_So9"] = row2["He_So1"];
                    }
                    else if (row["Dvt"].Equals(row2["Dvt2"]))
                    {
                        row["He_So9"] = row2["He_So2"];
                    }
                    row.EndEdit();
                }
            }
        }

        private void SetItemUnits()
        {
            if (!this.FormRequirement)
            {
                DataRow row = ((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row;
                DataRow row2 = AppDataAccess.SelectDataRow(false, "DMVT", "Ma_Vt", row["Ma_Vt"].ToString(), null);
                if (row2 != null)
                {
                    if (string.IsNullOrEmpty(row2["Dvt0"].ToString()))
                    {
                        base.DetailGridBrowser.CurrentCell.ReadOnly = true;
                    }
                    else
                    {
                        string str = (string.IsNullOrEmpty(row2["Dvt"].ToString()) ? "" : row2["Dvt"].ToString()) + (string.IsNullOrEmpty(row2["Dvt0"].ToString()) ? "" : ("," + row2["Dvt0"].ToString())) + (string.IsNullOrEmpty(row2["Dvt1"].ToString()) ? "" : ("," + row2["Dvt1"].ToString())) + (string.IsNullOrEmpty(row2["Dvt2"].ToString()) ? "" : ("," + row2["Dvt2"].ToString())) + (string.IsNullOrEmpty(row2["Dvt3"].ToString()) ? "" : ("," + row2["Dvt3"].ToString()));
                        (base.DetailGridBrowser.CurrentCell as OptionCell).InputMask = str;
                        base.DetailGridBrowser.CurrentCell.ReadOnly = false;
                    }
                }
            }
        }

        private bool Sum()
        {
            decimal num = 0M;
            decimal num2 = 0M;
            decimal num3 = 0M;
            decimal num4 = 0M;
            foreach (DataRow row in base.LocalDetailTable.Rows)
            {
                if (row.RowState != DataRowState.Deleted)
                {
                    num += (decimal) row["Tien_Nt"];
                    num2 += (decimal) row["Tien"];
                    num3 += (decimal) row["Tien_Nt1"];
                    num4 += (decimal) row["Tien1"];
                }
            }
            base.LocalMasterRow["TTien_Nt0"] = num + num3;
            base.LocalMasterRow["TTien0"] = num2 + num4;
            base.LocalMasterRow["TTien_Nt"] = num;
            base.LocalMasterRow["TTien"] = num2;
            base.LocalMasterRow["TTien_Nt1"] = num3;
            base.LocalMasterRow["TTien1"] = num4;
            this.txtTTien_Nt0.Value = num + num3;
            return true;
        }

        private void txtMa_Bp_Validated(object sender, EventArgs e)
        {
            if (this.txtMa_Bp.ValueChanged)
            {
                foreach (DataRow row in base.LocalDetailTable.Rows)
                {
                    if ((row.RowState != DataRowState.Deleted) && (this.txtMa_Bp.OldValue.Equals(row["Ma_Bp"]) || (this.txtMa_Bp.OldValue.ToString() == row["Ma_Bp"].ToString())))
                    {
                        row["Ma_Bp"] = this.txtMa_Bp.Value;
                        row["Ten_Bp"] = this.txtTen_Bp.Value;
                    }
                }
            }
        }

        private void txtMa_Dt_Validated(object sender, EventArgs e)
        {
            if (this.txtMa_Dt.ValueChanged)
            {
                this.txtOng_Ba.Value = this.txtMa_Dt.GetFieldData("Doi_Tac").Equals(DBNull.Value) ? this.txtTen_Dt.Value : this.txtMa_Dt.GetFieldData("Doi_Tac");
                this.txtDia_Chi.Value = this.txtMa_Dt.GetFieldData("Dia_Chi");
                this.txtPhones.Value = this.txtMa_Dt.GetFieldData("Phones");
                this.txtEmail.Value = this.txtMa_Dt.GetFieldData("Email");
            }
        }

        private void txtMa_Hd_Validated(object sender, EventArgs e)
        {
            if (this.txtMa_Hd.ValueChanged)
            {
                foreach (DataRow row in base.LocalDetailTable.Rows)
                {
                    if ((row.RowState != DataRowState.Deleted) && (this.txtMa_Hd.OldValue.Equals(row["Ma_Hd"]) || (this.txtMa_Hd.OldValue.ToString() == row["Ma_Hd"].ToString())))
                    {
                        row["Ma_Hd"] = this.txtMa_Hd.Value;
                        row["Ten_Hd"] = this.txtTen_Hd.Value;
                    }
                }
            }
        }

        private void txtMa_Tte_Validated(object sender, EventArgs e)
        {
            if (((base.AppInvoiceParameters != null) && (base.LocalMasterRow != null)) && this.txtMa_Tte.ValueChanged)
            {
                base.TranCurrencyCode = this.txtMa_Tte.Text;
                this.txtTy_Gia.Value = base.ExchangeRateOfBook;
                foreach (DataRow row in base.LocalDetailTable.Rows)
                {
                    if (row.RowState != DataRowState.Deleted)
                    {
                        this.Calculate(row, 2);
                    }
                }
                this.Sum();
            }
        }

        private void txtTy_Gia_Validated(object sender, EventArgs e)
        {
            if (this.txtTy_Gia.ValueChanged)
            {
                base.ExchangeRateOfBook = (decimal) this.txtTy_Gia.Value;
                foreach (DataRow row in base.LocalDetailTable.Rows)
                {
                    if (row.RowState != DataRowState.Deleted)
                    {
                        this.Calculate(row, 2);
                    }
                }
                this.Sum();
            }
        }

        public bool FormRequirement
        {
            get
            {
                return this.ib_FromRequirement;
            }
            set
            {
                this.ib_FromRequirement = value;
            }
        }
    }
}

